﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;


namespace OpenANDClose
{
    public class cl_0423_DevicePackage : cl_0423_Device
    {

        private List<cl_0423_Device> list = new List<cl_0423_Device>();



        public void addDevice(cl_0423_Device device)
        {
            list.Add(device);
        }

        public void removeDevice(cl_0423_Device device)
        {
            list.Remove(device);
        }

        public override void open()
        {
         
            for(int index=0;index<list.Count;index++)
            {
                Console.WriteLine((index+1)+"号:");
                list[index].open();
                
            }
            //  int index = 1;
            /* for (cl_0423_Device device:list)
             {
                 Console.WriteLine(index + "号");
                 device.open();
                 index++;
             }*/
        }

        public override void close()
        {
            for (int index = 0; index < list.Count; index++)
            {
                Console.WriteLine((index + 1) + "号:");
                list[index].close();

            }
        }
    }
}